package com.momo.momobackendjudgeservice.judge;

import com.momo.momobackendjudgeservice.judge.strategy.DefaultJudgeStrategy;
import com.momo.momobackendjudgeservice.judge.strategy.JavaLanguageJudgeStrategy;
import com.momo.momobackendjudgeservice.judge.strategy.JudgeContext;
import com.momo.momobackendjudgeservice.judge.strategy.JudgeStrategy;
import com.momo.momobackendmodel.codesandbox.JudgeInfo;
import com.momo.momobackendmodel.model.entity.QuestionSubmit;
import org.springframework.stereotype.Service;

/**
 * @author 十三
 * @create 2024-03-03 21:00
 * @Description:
 */
@Service
public class JudgeManager {

    JudgeInfo doJudge(JudgeContext judgeContext){
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategy();
        if ("java".equals(language)){
            judgeStrategy = new JavaLanguageJudgeStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);
    }
}
